//package com.zdx.yswl.view.listview;
//
//import java.util.ArrayList;
//
//import android.content.Context;
//import android.widget.BaseAdapter;
//
//public abstract class BaseListViewAdapter<T> extends BaseAdapter {
//
//	public ArrayList<T> dataList = new ArrayList<T>();
//	protected Context context;
//
//	public BaseListViewAdapter(Context _context) {
//		this.context = _context;
//	}
//
//	public BaseListViewAdapter(Context _context, ArrayList<T> _data) {
//		this(_context);
//		this.dataList = _data;
//	}
//	
//	public void addData(ArrayList<T> _dataList){
//		for(T _t : _dataList){
//			this.dataList.add(_t);
//		}
//		this.notifyDataSetChanged();
//	}
//
//	public void setData(ArrayList<T> _dataList) {
//		this.dataList = _dataList;
//		this.notifyDataSetChanged();
//	}
//
//	@Override
//	public int getCount() {
//		try {
//			return dataList.size();
//		} catch (Exception e) {
//			return 0;
//		}
//	}
//
//	@Override
//	public T getItem(int _position) {
//		try {
//			return dataList.get(_position);
//		} catch (Exception e) {
//			return null;
//		}
//	}
//
//	@Override
//	public long getItemId(int position) {
//		return position;
//	}
//
//}

package com.zdx.yswl.view.listview;

import java.util.ArrayList;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.zdx.yswl.R;

import android.content.Context;
import android.widget.BaseAdapter;

public abstract class BaseListViewAdapter<T> extends BaseAdapter {

	public ArrayList<T> dataList = new ArrayList<T>();
	protected Context context;

	protected DisplayImageOptions options;
	public BaseListViewAdapter(Context _context) {
		this.context = _context;
		options = new DisplayImageOptions.Builder()
		.showImageOnLoading(R.drawable.aio_image_default_round)
		.showImageForEmptyUri(R.drawable.aio_image_default_round)
		.showImageOnFail(R.drawable.aio_image_fail_round)
		 .considerExifParams(true)
		.imageScaleType(ImageScaleType.IN_SAMPLE_INT)
		.cacheInMemory(true)
		.cacheOnDisc(true)//设置下载的图片是否缓存在SD卡中  
		.considerExifParams(true)
		.imageScaleType(ImageScaleType.EXACTLY)
//		.displayer(new RoundedBitmapDisplayer(20))//设置图片圆角
		.build();
	}

	public BaseListViewAdapter(Context _context, ArrayList<T> _data) {
		this(_context);
		this.dataList = _data;
	}
	
	public void addData(ArrayList<T> _dataList){
		for(T _t : _dataList){
			this.dataList.add(_t);
		}
		this.notifyDataSetChanged();
	}

	public void setData(ArrayList<T> _dataList) {
		this.dataList = _dataList;
		this.notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		try {
			return dataList.size();
		} catch (Exception e) {
			return 0;
		}
	}

	@Override
	public T getItem(int _position) {
		try {
			return dataList.get(_position);
		} catch (Exception e) {
			return null;
		}
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

}

